import Vue from 'vue'
import I18n from 'vue-i18n'
import zh from './zh'
import en from './en'
import tw from './tw'
import iviewEn from 'iview/dist/locale/en-US'
import iviewZh from 'iview/dist/locale/zh-CN'
import iviewTW from 'iview/dist/locale/zh-TW'

Vue.use(I18n)
const messages = {
    en: Object.assign(en, iviewEn),
    zh: Object.assign(zh, iviewZh),
    tw: Object.assign(tw,iviewTW),
}

function getLocal () {
    let lang = 'zh'
    if (Vue.env && Vue.env.language) {
        lang = Vue.env.language
    }
    localStorage.setItem('lang','zh');
    localStorage.setItem('language','简体中文');
    return lang
}

const i18n = new I18n({
    locale: getLocal(),
    messages
})

export default i18n
